<!DOCTYPE html>
<html>

<head>
  <meta charset="UTF-8">
  <title>计算年终奖</title>
</head>

<body>
  工龄:<input type="text" value="1" id="workYear"><br>
  月薪:<input type="text" value="14000" id="workMoney"><br>
  <button id="submit">计算年终奖</button><br>
  你的年终奖是多少: ￥ <span id="valBox"></span>

  <script>
    let workYear = document.getElementById('workYear');
    let workMoney = document.getElementById('workMoney');
    let submit = document.getElementById('submit');
    let valBox = document.getElementById('valBox');

    submit.onclick = function () {
      // 获取文本框中的信息
      let year = Number(workYear.value);
      let money = Number(workMoney.value);
      if (isNaN(year) || isNaN(money)) {
        alert('输入的内容是非法格式~~~');
        return;
      }
      // 经过逻辑处理, 计算出 结果
      let result = null;
      if (year < 1) {
        result = money >= 8000 ? money * 1.2 : money;
      } else if (year >= 1 && year < 2) {
        result = money >= 10000 ? money * 1.7 : money * 1.5;
      } else {
        result = money >= 12000 ? money * 3.2 : money * 3;
      }
      // 把结果复制给#valBox即可
      valBox.innerHTML = result;
    }
  </script>
</body>

</html>